package com.jiandaoshou.utils;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import com.jiandaoshou.R;

/**
 * Created by Administrator on 2016/9/26.
 */

public class ViewUtils {

    public static RelativeLayout viewAddProgress(Activity activity, View view){
        RelativeLayout layout = new RelativeLayout(activity);
        layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
        ProgressBar progressBar = (ProgressBar) LayoutInflater.from(activity).inflate(R.layout.progressbar, null);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
        layout.addView(view,params);
        params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.addView(progressBar,params);
        layout.setTag(progressBar);
        return layout;
    }
}
